from check_ip import check_ip, pickle, ALTERNATE_IP  # , daily_check


def load():
    with open('ip_avail.pk', 'rb') as file:
        try:
            ip_pool_ = pickle.load(file)
        except Exception as error:
            print('加载IP池异常，信息为：', f'{error}')
            print('启动备用IP池！\n备用IP池情况为：')
            ip_pool_ = ALTERNATE_IP
            for i in ip_pool_:
                print('该IP已失效：' if not check_ip(i) else '该IP可用！', f'{i}')
        else:
            print(f'IP池加载完毕，一切正常！')
            print(f'共{len(ip_pool_)}个IP！')
    return ip_pool_


ip_pool = load()

if __name__ == '__main__':
    print(ALTERNATE_IP)
